<template>
<!--  <div id="content">
    &lt;!&ndash; sideBar 侧边栏&ndash;&gt;
    <div class="sideBar">
      &lt;!&ndash; 最新推荐&ndash;&gt;
      <div class="sideBox" id="sideZxtj">
        <div class="hd">
          <h3><span>最新推荐</span></h3>
        </div>
        <div class="bd">
          <ul class="infoList infoListA">
            <li v-for="(item,index) in honourList.slice(0,10)" :key="index"
                style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
            >
              <a @click="btnClick(item)" href="javascript:;"
                 :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
              >{{ item.honourTitle }}</a>
            </li>
          </ul>
        </div>
      </div>

      &lt;!&ndash; 热榜推荐&ndash;&gt;
      <div class="sideBox" id="sideZxwz">
        <div class="hd">
          <h3><span>热榜推荐</span></h3>
        </div>
        <div class="bd">
          <ul class="infoList infoListA">
            <li v-for="(item,index) in honourListClick.slice(0,10)" :key="index"
                style="text-overflow: ellipsis; overflow: hidden; white-space: nowrap;"
            >
              <a @click="btnClick(item)" href="javascript:;"
                 :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
              >{{ item.honourTitle }}</a>
            </li>
          </ul>
        </div>
      </div>
    </div>

    &lt;!&ndash; 主要内容&ndash;&gt;
    <div class="mainContent" >
      &lt;!&ndash;      <div class="mianBox" id="articleList">
              <Breadcrumb></Breadcrumb>
              <div style="border-left: 1px solid #e6e6e6;border-right: 1px solid #e6e6e6;border-bottom: 1px solid #e6e6e6;">
                &lt;!&ndash; 列表信息&ndash;&gt;
                <div v-if="key==='/honour/list'" class="wBd">
                  <ul class="newsList" v-for="(item,index) in honourList" :key="index">
                    <li>
                      <span class="date">{{ parseTime(item.createTime, '{y}-{m}-{d}') }}</span>
                      <a @click="btnClick(item)" href="javascript:;"
                         :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                      >{{ vague('2', item.honourTitle) }}</a></li>
                    <li v-if="(index+1)%5===0" class="split"></li>
                  </ul>
                  <pagination
                    v-show="total>0"
                    :total="total"
                    :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getHonourList"
                  />
                </div>

                &lt;!&ndash; 正文内容&ndash;&gt;
                <router-view></router-view>
                &lt;!&ndash;          <router-view v-else :key="idChange"></router-view>&ndash;&gt;
              </div>
            </div>&ndash;&gt;
      <div class="mianBox" id="picChildList">
        <Breadcrumb></Breadcrumb>
        <div style="border-left: 1px solid #e6e6e6;border-right: 1px solid #e6e6e6;border-bottom: 1px solid #e6e6e6;">
          &lt;!&ndash; 列表信息&ndash;&gt;
          <div v-if="key==='/honour/list'" class="wBd" style="width: 100%;padding: 20px 10px;">
            <ul class="picList1">
              <li class="first" v-for="(item,index) in honourList" :key="index">
                <div class="pic" style="height: 163px">
                  <a @click="btnClick(item)" href="javascript:;"
                     :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                  >
                    <img :src="item.url">
&lt;!&ndash;                    <img :src="changeUrl(item.img[0].fileName)">&ndash;&gt;
                  </a>
                </div>
                <div class="title">
                  <a @click="btnClick(item)" href="javascript:;"
                     :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                  >{{ vague('6', item.honourTitle) }}</a>
                </div>
              </li>
            </ul>
            <pagination
              v-show="total>0"
              :total="total"
              :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize"
              @pagination="getHonourList"
            />
          </div>

          &lt;!&ndash; 正文内容&ndash;&gt;
          <router-view></router-view>
        </div>
      </div>
    </div>
  </div>-->
  <div id="content">
    <div class="mainContent" style="width: 100%;float: none">
      <!--      <div class="mianBox" id="articleList">
              <Breadcrumb></Breadcrumb>
              <div style="border-left: 1px solid #e6e6e6;border-right: 1px solid #e6e6e6;border-bottom: 1px solid #e6e6e6;">
                &lt;!&ndash; 列表信息&ndash;&gt;
                <div v-if="key==='/honour/list'" class="wBd">
                  <ul class="newsList" v-for="(item,index) in honourList" :key="index">
                    <li>
                      <span class="date">{{ parseTime(item.createTime, '{y}-{m}-{d}') }}</span>
                      <a @click="btnClick(item)" href="javascript:;"
                         :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                      >{{ vague('2', item.honourTitle) }}</a></li>
                    <li v-if="(index+1)%5===0" class="split"></li>
                  </ul>
                  <pagination
                    v-show="total>0"
                    :total="total"
                    :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize"
                    @pagination="getHonourList"
                  />
                </div>

                &lt;!&ndash; 正文内容&ndash;&gt;
                <router-view></router-view>
                &lt;!&ndash;          <router-view v-else :key="idChange"></router-view>&ndash;&gt;
              </div>
            </div>-->
      <div class="mianBox" id="picChildList">
        <Breadcrumb></Breadcrumb>
        <div style="border-left: 1px solid #e6e6e6;border-right: 1px solid #e6e6e6;border-bottom: 1px solid #e6e6e6;">
          <!-- 列表信息-->
          <div v-if="key==='/honour/list'" class="wBd" style="padding: 20px;">
            <ul class="picList1">
              <li :style="{'margin':((index+1)%4==0)?'0px':'0px 18px 0 0'}" class="first" v-for="(item,index) in honourList" :key="index">
                <div class="pic" style="height: 163px">
                  <a @click="btnClick(item)" href="javascript:;"
                     :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                  >
                    <img :src="item.url">
                    <!--                    <img :src="changeUrl(item.img[0].fileName)">-->
                  </a>
                </div>
                <div class="title">
                  <a @click="btnClick(item)" href="javascript:;"
                     :title="'标题：'+item.honourTitle+'\n'+'浏览量：'+item.click+'\n'+'发表时间：'+item.createTime"
                  >{{ vague('6', item.honourTitle) }}</a>
                </div>
              </li>
            </ul>
            <pagination
              v-show="total>0"
              :total="total"
              :page.sync="queryParams.pageNum"
              :limit.sync="queryParams.pageSize"
              @pagination="getHonourList"
            />
          </div>

          <!-- 正文内容-->
          <router-view></router-view>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { listHonour, listHonourClick, updateHonourClick } from '@/api/honour'

export default {
  name: 'Honour',
  inject: ['reloadMain'],
  data() {
    return {
      honourList: [], // 新闻数据
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        status: '0'
      },
      honourListClick: [],
      total: 0// 总条数
    }
  },
  computed: {
    key() {
      return this.$route.path
    }
  },
  created() {
    this.getHonourList()
  },
  methods: {
    //查询新闻列表
    getHonourList() {
      listHonour(this.queryParams).then(response => {
        // this.honourList = response.rows.filter(item => {
        //   if (item.img && item.img !== '[]') {
        //     return item
        //   }
        // })
        // this.honourList.map(item => {
        //   item.img = JSON.parse(item.img)
        // })
        this.honourList = response.rows
        this.honourList.map(item => {
          // item.img = this.change(item.img)
          item.url = this.getObjectKeys(item.honourContent)
        })
        this.total = response.total
      })
      /*listHonourClick(this.queryParams).then(response => {
        this.honourListClick = response.rows
      })*/
    },

    //点击选中
    btnClick(data) {
      data.img = JSON.stringify(data.img)
      updateHonourClick(data)
      this.$router.push({
        path: '/honour/list/edit',
        query: {
          id: data.honourId
        }
      })
      this.reloadMain()
    }
  }
}
</script>

<style scoped>

</style>
